{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from scipy.fftpack import fft2, ifft2\n",
    "from bokeh.plotting import figure, show, output_notebook\n",
    "from bokeh.io import push_notebook\n",
    "from time import sleep"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## algorithm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def conway(size, prob=.5):\n",
    "    # initialize game\n",
    "    board = (np.random.rand(size, size) < prob).astype(int)\n",
    "\n",
    "    # kernel\n",
    "    kernel = np.zeros(board.shape)\n",
    "    kernel[sorted([0, 1, -1] * 3), [-1, 0, 1] * 3] = 1\n",
    "    kernel[0, 0] = 10\n",
    "    kernel = fft2(kernel)\n",
    "    \n",
    "    # update step\n",
    "    def _conway():\n",
    "        cell = ifft2(fft2(board) * kernel).real.round()\n",
    "        board[:] = (cell == 3) | (cell == 12) | (cell == 13)\n",
    "        return board\n",
    "        \n",
    "    return _conway"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## plotting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def animate(game, frames=30):\n",
    "    frame = game()\n",
    "    \n",
    "    output_notebook()\n",
    "    \n",
    "    plot = figure(x_range=(0, 1), y_range=(0, 1), \n",
    "                  plot_width=frame.shape[1] * 5, \n",
    "                  plot_height=frame.shape[0] * 5)\n",
    "    plot.axis.visible = False\n",
    "    image = plot.image([frame], x=0, y=0, dw=1, dh=1)\n",
    "\n",
    "    handle = show(plot, notebook_handle=True)\n",
    "    \n",
    "    for i in range(frames):\n",
    "        image.data_source.data['image'] = [game()]\n",
    "        push_notebook()\n",
    "        sleep(.05)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## pulsar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"cc2565a7-d151-4b24-943f-752b1c7ba3af\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(global) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    window._bokeh_onload_callbacks = [];\n",
       "    window._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "\n",
       "  \n",
       "  if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    window._bokeh_timeout = Date.now() + 5000;\n",
       "    window._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    if (window.Bokeh !== undefined) {\n",
       "      document.getElementById(\"cc2565a7-d151-4b24-943f-752b1c7ba3af\").textContent = \"BokehJS successfully loaded.\";\n",
       "    } else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function run_callbacks() {\n",
       "    window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    delete window._bokeh_onload_callbacks\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    window._bokeh_onload_callbacks.push(callback);\n",
       "    if (window._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    window._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        window._bokeh_is_loading--;\n",
       "        if (window._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"cc2565a7-d151-4b24-943f-752b1c7ba3af\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'cc2565a7-d151-4b24-943f-752b1c7ba3af' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.4.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "      document.getElementById(\"cc2565a7-d151-4b24-943f-752b1c7ba3af\").textContent = \"BokehJS is loading...\";\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.4.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.4.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.4.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.4.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i](window.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!window._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      window._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"cc2565a7-d151-4b24-943f-752b1c7ba3af\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (window._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(this));"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"e11fdb0e-5f4d-4896-b32e-c6b33c9b4d2d\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(global) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      window._bokeh_onload_callbacks = [];\n",
       "      window._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      window._bokeh_timeout = Date.now() + 0;\n",
       "      window._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (window.Bokeh !== undefined) {\n",
       "        document.getElementById(\"e11fdb0e-5f4d-4896-b32e-c6b33c9b4d2d\").textContent = \"BokehJS successfully loaded.\";\n",
       "      } else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }if ((window.Jupyter !== undefined) && Jupyter.notebook.kernel) {\n",
       "      comm_manager = Jupyter.notebook.kernel.comm_manager\n",
       "      comm_manager.register_target(\"9e46cfcb-cdd2-4c6f-80cc-bfcd3daad915\", function () {});\n",
       "    }\n",
       "  \n",
       "    function run_callbacks() {\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      delete window._bokeh_onload_callbacks\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      window._bokeh_onload_callbacks.push(callback);\n",
       "      if (window._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      window._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          window._bokeh_is_loading--;\n",
       "          if (window._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"e11fdb0e-5f4d-4896-b32e-c6b33c9b4d2d\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'e11fdb0e-5f4d-4896-b32e-c6b33c9b4d2d' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"d890cd10-37b5-4699-8257-6edd6123aa11\":{\"roots\":{\"references\":[{\"attributes\":{\"callback\":null},\"id\":\"cc728cf6-a74e-4c9d-87ac-e31bc17aa478\",\"type\":\"Range1d\"},{\"attributes\":{\"palette\":[\"#000000\",\"#252525\",\"#525252\",\"#737373\",\"#969696\",\"#bdbdbd\",\"#d9d9d9\",\"#f0f0f0\",\"#ffffff\"]},\"id\":\"0d2127a2-ac63-42a7-9cc1-97706ca7ec88\",\"type\":\"LinearColorMapper\"},{\"attributes\":{},\"id\":\"0c6f70d5-9d54-40aa-99f3-9a6301899300\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0c6f70d5-9d54-40aa-99f3-9a6301899300\",\"type\":\"BasicTicker\"}},\"id\":\"2005dbc6-07ff-4712-adde-b30adc97dbc3\",\"type\":\"Grid\"},{\"attributes\":{\"overlay\":{\"id\":\"19d6c70b-d632-4635-9564-6d43fbc7b8c3\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"88688c42-05ac-4afe-9812-432e0797d888\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"formatter\":{\"id\":\"99f9aebd-909b-4cf0-9dc4-391f1ce88dbb\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"b4b061ea-3425-4bf0-b838-8c9e1290cf00\",\"type\":\"BasicTicker\"},\"visible\":false},\"id\":\"812ffec5-00db-411f-b4a1-94a6b03392ad\",\"type\":\"LinearAxis\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"b4b061ea-3425-4bf0-b838-8c9e1290cf00\",\"type\":\"BasicTicker\"}},\"id\":\"6ef69bc5-3fbc-4c09-b8e7-e7d8e5861a97\",\"type\":\"Grid\"},{\"attributes\":{\"data_source\":{\"id\":\"292df198-61bd-408b-abcd-8a480a58aa85\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"26582fb3-f615-43a9-827c-49d57c29332d\",\"type\":\"Image\"},\"hover_glyph\":null,\"nonselection_glyph\":{\"id\":\"7a5fa08e-ec24-461c-85e3-e155c490d4bb\",\"type\":\"Image\"},\"selection_glyph\":null},\"id\":\"07986f3c-0488-4ed0-9d19-cc7e61c2d596\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"19d6c70b-d632-4635-9564-6d43fbc7b8c3\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"formatter\":{\"id\":\"f70c43a0-7a01-4422-abaf-1423d24347fe\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0c6f70d5-9d54-40aa-99f3-9a6301899300\",\"type\":\"BasicTicker\"},\"visible\":false},\"id\":\"aab9d826-db1e-410f-9c39-228016921270\",\"type\":\"LinearAxis\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"cb6942cc-8964-4013-ba3a-96ce9e880276\",\"type\":\"PanTool\"},{\"id\":\"52b27929-f59a-414e-bec0-c5c7725aa2b2\",\"type\":\"WheelZoomTool\"},{\"id\":\"88688c42-05ac-4afe-9812-432e0797d888\",\"type\":\"BoxZoomTool\"},{\"id\":\"c5d13956-67a1-40ac-8136-d121542e9389\",\"type\":\"SaveTool\"},{\"id\":\"b8dd1ac9-aaa3-4cbd-b457-cf548f1a989b\",\"type\":\"ResetTool\"},{\"id\":\"7bf29056-d5d7-461d-9d09-c349a568334c\",\"type\":\"HelpTool\"}]},\"id\":\"50cf312a-ccfb-465b-ad71-174b99adcf9b\",\"type\":\"Toolbar\"},{\"attributes\":{\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"52b27929-f59a-414e-bec0-c5c7725aa2b2\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"b4b061ea-3425-4bf0-b838-8c9e1290cf00\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"image\"],\"data\":{\"image\":[[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,1,0,0,0,0,0,1,0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,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]]}},\"id\":\"292df198-61bd-408b-abcd-8a480a58aa85\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"cb6942cc-8964-4013-ba3a-96ce9e880276\",\"type\":\"PanTool\"},{\"attributes\":{\"callback\":null},\"id\":\"b43ec261-cbed-42d6-bc07-c3eb495d8b81\",\"type\":\"Range1d\"},{\"attributes\":{\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"c5d13956-67a1-40ac-8136-d121542e9389\",\"type\":\"SaveTool\"},{\"attributes\":{\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"b8dd1ac9-aaa3-4cbd-b457-cf548f1a989b\",\"type\":\"ResetTool\"},{\"attributes\":{\"color_mapper\":{\"id\":\"8bd75c40-18c5-4d96-9aa4-693b4f93258b\",\"type\":\"LinearColorMapper\"},\"dh\":{\"units\":\"data\",\"value\":1},\"dw\":{\"units\":\"data\",\"value\":1},\"image\":{\"field\":\"image\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"26582fb3-f615-43a9-827c-49d57c29332d\",\"type\":\"Image\"},{\"attributes\":{},\"id\":\"99f9aebd-909b-4cf0-9dc4-391f1ce88dbb\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"below\":[{\"id\":\"aab9d826-db1e-410f-9c39-228016921270\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"812ffec5-00db-411f-b4a1-94a6b03392ad\",\"type\":\"LinearAxis\"}],\"plot_height\":250,\"plot_width\":250,\"renderers\":[{\"id\":\"aab9d826-db1e-410f-9c39-228016921270\",\"type\":\"LinearAxis\"},{\"id\":\"2005dbc6-07ff-4712-adde-b30adc97dbc3\",\"type\":\"Grid\"},{\"id\":\"812ffec5-00db-411f-b4a1-94a6b03392ad\",\"type\":\"LinearAxis\"},{\"id\":\"6ef69bc5-3fbc-4c09-b8e7-e7d8e5861a97\",\"type\":\"Grid\"},{\"id\":\"19d6c70b-d632-4635-9564-6d43fbc7b8c3\",\"type\":\"BoxAnnotation\"},{\"id\":\"07986f3c-0488-4ed0-9d19-cc7e61c2d596\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"a60578fd-9838-4cad-ad59-b76b811a6af5\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"f0456884-503b-49aa-b826-0872c7634067\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"50cf312a-ccfb-465b-ad71-174b99adcf9b\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"b43ec261-cbed-42d6-bc07-c3eb495d8b81\",\"type\":\"Range1d\"},\"y_range\":{\"id\":\"cc728cf6-a74e-4c9d-87ac-e31bc17aa478\",\"type\":\"Range1d\"}},\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"f0456884-503b-49aa-b826-0872c7634067\",\"type\":\"ToolEvents\"},{\"attributes\":{},\"id\":\"f70c43a0-7a01-4422-abaf-1423d24347fe\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"7bf29056-d5d7-461d-9d09-c349a568334c\",\"type\":\"HelpTool\"},{\"attributes\":{\"palette\":[\"#000000\",\"#252525\",\"#525252\",\"#737373\",\"#969696\",\"#bdbdbd\",\"#d9d9d9\",\"#f0f0f0\",\"#ffffff\"]},\"id\":\"8bd75c40-18c5-4d96-9aa4-693b4f93258b\",\"type\":\"LinearColorMapper\"},{\"attributes\":{\"color_mapper\":{\"id\":\"0d2127a2-ac63-42a7-9cc1-97706ca7ec88\",\"type\":\"LinearColorMapper\"},\"dh\":{\"units\":\"data\",\"value\":1},\"dw\":{\"units\":\"data\",\"value\":1},\"image\":{\"field\":\"image\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"7a5fa08e-ec24-461c-85e3-e155c490d4bb\",\"type\":\"Image\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"a60578fd-9838-4cad-ad59-b76b811a6af5\",\"type\":\"Title\"}],\"root_ids\":[\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.4\"}};\n",
       "            var render_items = [{\"docid\":\"d890cd10-37b5-4699-8257-6edd6123aa11\",\"elementid\":\"e11fdb0e-5f4d-4896-b32e-c6b33c9b4d2d\",\"modelid\":\"a8c33a56-d8f8-4d5c-a690-b3d3babb4319\",\"notebook_comms_target\":\"9e46cfcb-cdd2-4c6f-80cc-bfcd3daad915\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i](window.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!window._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        window._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"e11fdb0e-5f4d-4896-b32e-c6b33c9b4d2d\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (window._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(this));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "game = conway(50, .0)\n",
    "board = game()\n",
    "\n",
    "# pulsar\n",
    "index = [4, 5, 6, 10, 11, 12]\n",
    "board[2, index] = 1\n",
    "board[7, index] = 1\n",
    "board[9, index] = 1\n",
    "board[14, index] = 1\n",
    "board[index, 2] = 1\n",
    "board[index, 7] = 1\n",
    "board[index, 9] = 1\n",
    "board[index, 14] = 1\n",
    "\n",
    "# glider\n",
    "board[[30, 30, 30, 31, 32], [30, 31, 32, 30, 31]] = 1\n",
    "\n",
    "# animate\n",
    "animate(game, frames=200)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## random game"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"f3c96d14-2c63-4627-8a44-35e1e1a1f2d0\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(global) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    window._bokeh_onload_callbacks = [];\n",
       "    window._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "\n",
       "  \n",
       "  if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    window._bokeh_timeout = Date.now() + 5000;\n",
       "    window._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    if (window.Bokeh !== undefined) {\n",
       "      document.getElementById(\"f3c96d14-2c63-4627-8a44-35e1e1a1f2d0\").textContent = \"BokehJS successfully loaded.\";\n",
       "    } else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function run_callbacks() {\n",
       "    window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    delete window._bokeh_onload_callbacks\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    window._bokeh_onload_callbacks.push(callback);\n",
       "    if (window._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    window._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        window._bokeh_is_loading--;\n",
       "        if (window._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"f3c96d14-2c63-4627-8a44-35e1e1a1f2d0\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'f3c96d14-2c63-4627-8a44-35e1e1a1f2d0' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.4.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.4.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "      document.getElementById(\"f3c96d14-2c63-4627-8a44-35e1e1a1f2d0\").textContent = \"BokehJS is loading...\";\n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.4.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.4.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.4.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.4.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i](window.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < window._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!window._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      window._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"f3c96d14-2c63-4627-8a44-35e1e1a1f2d0\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (window._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(this));"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <div class=\"bk-plotdiv\" id=\"64f1e7a9-9f30-47ee-9561-e21b3a2a9c08\"></div>\n",
       "    </div>\n",
       "<script type=\"text/javascript\">\n",
       "  \n",
       "  (function(global) {\n",
       "    function now() {\n",
       "      return new Date();\n",
       "    }\n",
       "  \n",
       "    var force = false;\n",
       "  \n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "      window._bokeh_onload_callbacks = [];\n",
       "      window._bokeh_is_loading = undefined;\n",
       "    }\n",
       "  \n",
       "  \n",
       "    \n",
       "    if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "      window._bokeh_timeout = Date.now() + 0;\n",
       "      window._bokeh_failed_load = false;\n",
       "    }\n",
       "  \n",
       "    var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "       \"<div style='background-color: #fdd'>\\n\"+\n",
       "       \"<p>\\n\"+\n",
       "       \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "       \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "       \"</p>\\n\"+\n",
       "       \"<ul>\\n\"+\n",
       "       \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "       \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "       \"</ul>\\n\"+\n",
       "       \"<code>\\n\"+\n",
       "       \"from bokeh.resources import INLINE\\n\"+\n",
       "       \"output_notebook(resources=INLINE)\\n\"+\n",
       "       \"</code>\\n\"+\n",
       "       \"</div>\"}};\n",
       "  \n",
       "    function display_loaded() {\n",
       "      if (window.Bokeh !== undefined) {\n",
       "        document.getElementById(\"64f1e7a9-9f30-47ee-9561-e21b3a2a9c08\").textContent = \"BokehJS successfully loaded.\";\n",
       "      } else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(display_loaded, 100)\n",
       "      }\n",
       "    }if ((window.Jupyter !== undefined) && Jupyter.notebook.kernel) {\n",
       "      comm_manager = Jupyter.notebook.kernel.comm_manager\n",
       "      comm_manager.register_target(\"6f5ff43f-86c0-4558-ad00-00fb6f14dbf5\", function () {});\n",
       "    }\n",
       "  \n",
       "    function run_callbacks() {\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "      delete window._bokeh_onload_callbacks\n",
       "      console.info(\"Bokeh: all callbacks have finished\");\n",
       "    }\n",
       "  \n",
       "    function load_libs(js_urls, callback) {\n",
       "      window._bokeh_onload_callbacks.push(callback);\n",
       "      if (window._bokeh_is_loading > 0) {\n",
       "        console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "        return null;\n",
       "      }\n",
       "      if (js_urls == null || js_urls.length === 0) {\n",
       "        run_callbacks();\n",
       "        return null;\n",
       "      }\n",
       "      console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "      window._bokeh_is_loading = js_urls.length;\n",
       "      for (var i = 0; i < js_urls.length; i++) {\n",
       "        var url = js_urls[i];\n",
       "        var s = document.createElement('script');\n",
       "        s.src = url;\n",
       "        s.async = false;\n",
       "        s.onreadystatechange = s.onload = function() {\n",
       "          window._bokeh_is_loading--;\n",
       "          if (window._bokeh_is_loading === 0) {\n",
       "            console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "            run_callbacks()\n",
       "          }\n",
       "        };\n",
       "        s.onerror = function() {\n",
       "          console.warn(\"failed to load library \" + url);\n",
       "        };\n",
       "        console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "        document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "      }\n",
       "    };var element = document.getElementById(\"64f1e7a9-9f30-47ee-9561-e21b3a2a9c08\");\n",
       "    if (element == null) {\n",
       "      console.log(\"Bokeh: ERROR: autoload.js configured with elementid '64f1e7a9-9f30-47ee-9561-e21b3a2a9c08' but no matching script tag was found. \")\n",
       "      return false;\n",
       "    }\n",
       "  \n",
       "    var js_urls = [];\n",
       "  \n",
       "    var inline_js = [\n",
       "      function(Bokeh) {\n",
       "        (function() {\n",
       "          var fn = function() {\n",
       "            var docs_json = {\"16368f12-4bb5-4591-949e-37a1c86e2adc\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"03f0e690-7b94-4db7-a68a-a97dd454b9df\",\"type\":\"BasicTicker\"},{\"attributes\":{\"palette\":[\"#000000\",\"#252525\",\"#525252\",\"#737373\",\"#969696\",\"#bdbdbd\",\"#d9d9d9\",\"#f0f0f0\",\"#ffffff\"]},\"id\":\"901775c6-9d95-49b0-b87e-ab71ab4e9e9e\",\"type\":\"LinearColorMapper\"},{\"attributes\":{\"formatter\":{\"id\":\"8cca838a-db05-4f9a-ab7c-75edfd3e965f\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"9e3b371d-8909-490d-b0e6-af7f0351d8dc\",\"type\":\"BasicTicker\"},\"visible\":false},\"id\":\"d3634899-7576-48d9-b309-1cc443ab942c\",\"type\":\"LinearAxis\"},{\"attributes\":{\"palette\":[\"#000000\",\"#252525\",\"#525252\",\"#737373\",\"#969696\",\"#bdbdbd\",\"#d9d9d9\",\"#f0f0f0\",\"#ffffff\"]},\"id\":\"136fafc8-cfe1-4721-910f-6aed4306da72\",\"type\":\"LinearColorMapper\"},{\"attributes\":{\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"38916120-1b50-4c18-a6c3-8515833bf41e\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"image\"],\"data\":{\"image\":[[[0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],[0,0,0,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1],[0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,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47ab-a8a0-da25b35ed543\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"89f2e8d0-2044-46d8-a165-af8b6c8983a9\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"e4ea5ba9-876e-4e9a-a352-2439484e50aa\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"6e080d90-ba73-47ab-a8a0-da25b35ed543\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"5bbf11ac-988e-4301-81b1-5961c1f4c41c\",\"type\":\"Image\"},\"hover_glyph\":null,\"nonselection_glyph\":{\"id\":\"0c64ec1f-b072-4b2b-b1a6-57c4fee44431\",\"type\":\"Image\"},\"selection_glyph\":null},\"id\":\"3eb47923-6627-4c9e-a73c-dc8c7c44d6f7\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"color_mapper\":{\"id\":\"901775c6-9d95-49b0-b87e-ab71ab4e9e9e\",\"type\":\"LinearColorMapper\"},\"dh\":{\"units\":\"data\",\"value\":1},\"dw\":{\"units\":\"data\",\"value\":1},\"image\":{\"field\":\"image\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"0c64ec1f-b072-4b2b-b1a6-57c4fee44431\",\"type\":\"Image\"},{\"attributes\":{\"overlay\":{\"id\":\"89f2e8d0-2044-46d8-a165-af8b6c8983a9\",\"type\":\"BoxAnnotation\"},\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"0985fa83-2f51-4b03-ba28-f051c9109ef7\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"56b5b7fd-b829-4ade-b383-cbcfcc9eece7\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"5c22405c-4446-4275-9434-09111d4d955d\",\"type\":\"HelpTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"f356eb4b-92ea-4aa8-9623-a44c3a13fa85\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"8cca838a-db05-4f9a-ab7c-75edfd3e965f\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"4e73dcff-b572-4a70-b612-4d083d8374cc\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"ebd616f0-6b8f-47bb-955f-c0901ea2762c\",\"type\":\"SaveTool\"},{\"attributes\":{\"callback\":null},\"id\":\"843a6906-8646-478c-9d0c-83d3a5dc8ead\",\"type\":\"Range1d\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"e4ea5ba9-876e-4e9a-a352-2439484e50aa\",\"type\":\"PanTool\"},{\"id\":\"38916120-1b50-4c18-a6c3-8515833bf41e\",\"type\":\"WheelZoomTool\"},{\"id\":\"0985fa83-2f51-4b03-ba28-f051c9109ef7\",\"type\":\"BoxZoomTool\"},{\"id\":\"ebd616f0-6b8f-47bb-955f-c0901ea2762c\",\"type\":\"SaveTool\"},{\"id\":\"56b5b7fd-b829-4ade-b383-cbcfcc9eece7\",\"type\":\"ResetTool\"},{\"id\":\"5c22405c-4446-4275-9434-09111d4d955d\",\"type\":\"HelpTool\"}]},\"id\":\"cf3e3f0c-104c-4bad-94fc-14bebc1a00b6\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"9e3b371d-8909-490d-b0e6-af7f0351d8dc\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"d148ee0a-049d-4933-86ec-ac0a64296822\",\"type\":\"ToolEvents\"},{\"attributes\":{\"below\":[{\"id\":\"09ca50fa-3beb-4d9d-ab6b-98f8676d405e\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"d3634899-7576-48d9-b309-1cc443ab942c\",\"type\":\"LinearAxis\"}],\"plot_height\":350,\"plot_width\":350,\"renderers\":[{\"id\":\"09ca50fa-3beb-4d9d-ab6b-98f8676d405e\",\"type\":\"LinearAxis\"},{\"id\":\"7895da88-f9c7-419d-9c2e-67ed0445ed59\",\"type\":\"Grid\"},{\"id\":\"d3634899-7576-48d9-b309-1cc443ab942c\",\"type\":\"LinearAxis\"},{\"id\":\"44e6e1e0-5868-4add-8446-9acf22448e3e\",\"type\":\"Grid\"},{\"id\":\"89f2e8d0-2044-46d8-a165-af8b6c8983a9\",\"type\":\"BoxAnnotation\"},{\"id\":\"3eb47923-6627-4c9e-a73c-dc8c7c44d6f7\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"f356eb4b-92ea-4aa8-9623-a44c3a13fa85\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"d148ee0a-049d-4933-86ec-ac0a64296822\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"cf3e3f0c-104c-4bad-94fc-14bebc1a00b6\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"843a6906-8646-478c-9d0c-83d3a5dc8ead\",\"type\":\"Range1d\"},\"y_range\":{\"id\":\"cef182dc-cc66-4439-81b9-d15d7a91c45b\",\"type\":\"Range1d\"}},\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"9e3b371d-8909-490d-b0e6-af7f0351d8dc\",\"type\":\"BasicTicker\"}},\"id\":\"44e6e1e0-5868-4add-8446-9acf22448e3e\",\"type\":\"Grid\"},{\"attributes\":{\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"03f0e690-7b94-4db7-a68a-a97dd454b9df\",\"type\":\"BasicTicker\"}},\"id\":\"7895da88-f9c7-419d-9c2e-67ed0445ed59\",\"type\":\"Grid\"},{\"attributes\":{\"color_mapper\":{\"id\":\"136fafc8-cfe1-4721-910f-6aed4306da72\",\"type\":\"LinearColorMapper\"},\"dh\":{\"units\":\"data\",\"value\":1},\"dw\":{\"units\":\"data\",\"value\":1},\"image\":{\"field\":\"image\"},\"x\":{\"value\":0},\"y\":{\"value\":0}},\"id\":\"5bbf11ac-988e-4301-81b1-5961c1f4c41c\",\"type\":\"Image\"},{\"attributes\":{\"callback\":null},\"id\":\"cef182dc-cc66-4439-81b9-d15d7a91c45b\",\"type\":\"Range1d\"},{\"attributes\":{\"formatter\":{\"id\":\"4e73dcff-b572-4a70-b612-4d083d8374cc\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"03f0e690-7b94-4db7-a68a-a97dd454b9df\",\"type\":\"BasicTicker\"},\"visible\":false},\"id\":\"09ca50fa-3beb-4d9d-ab6b-98f8676d405e\",\"type\":\"LinearAxis\"}],\"root_ids\":[\"7725fa50-c4c2-40d1-8314-3d5e92305b57\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.4\"}};\n",
       "            var render_items = [{\"docid\":\"16368f12-4bb5-4591-949e-37a1c86e2adc\",\"elementid\":\"64f1e7a9-9f30-47ee-9561-e21b3a2a9c08\",\"modelid\":\"7725fa50-c4c2-40d1-8314-3d5e92305b57\",\"notebook_comms_target\":\"6f5ff43f-86c0-4558-ad00-00fb6f14dbf5\"}];\n",
       "            \n",
       "            Bokeh.embed.embed_items(docs_json, render_items);\n",
       "          };\n",
       "          if (document.readyState != \"loading\") fn();\n",
       "          else document.addEventListener(\"DOMContentLoaded\", fn);\n",
       "        })();\n",
       "      },\n",
       "      function(Bokeh) {\n",
       "      }\n",
       "    ];\n",
       "  \n",
       "    function run_inline_js() {\n",
       "      \n",
       "      if ((window.Bokeh !== undefined) || (force === true)) {\n",
       "        for (var i = 0; i < inline_js.length; i++) {\n",
       "          inline_js[i](window.Bokeh);\n",
       "        }if (force === true) {\n",
       "          display_loaded();\n",
       "        }} else if (Date.now() < window._bokeh_timeout) {\n",
       "        setTimeout(run_inline_js, 100);\n",
       "      } else if (!window._bokeh_failed_load) {\n",
       "        console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "        window._bokeh_failed_load = true;\n",
       "      } else if (force !== true) {\n",
       "        var cell = $(document.getElementById(\"64f1e7a9-9f30-47ee-9561-e21b3a2a9c08\")).parents('.cell').data().cell;\n",
       "        cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "      }\n",
       "  \n",
       "    }\n",
       "  \n",
       "    if (window._bokeh_is_loading === 0) {\n",
       "      console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "      run_inline_js();\n",
       "    } else {\n",
       "      load_libs(js_urls, function() {\n",
       "        console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "        run_inline_js();\n",
       "      });\n",
       "    }\n",
       "  }(this));\n",
       "</script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "animate(conway(70, .2), frames=200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
